package books4africa

//INTEGRATION TEST

import static org.junit.Assert.*
import org.junit.*

class BookRequestTests {

	void testPersistence(){
		
		BookRequest test = new BookRequest(requestDescription: "test", title: 'Title', category: "category", gradeLower: 1, gradeHigher: 6, qty: 20, dateMinString: "min", dateMaxString: "max").save()
		
		BookRequest retrieved = BookRequest.findByTitle("Title");
		
		println retrieved.title
		
		assertEquals(test, retrieved)
		
	}
	
	void testFulfillmentList(){
		BookRequest bookRequest = new BookRequest(requestDescription: "test", title: 'Title', category: "category", gradeLower: 1, gradeHigher: 6, qty: 20, dateMinString: "min", dateMaxString: "max").save()
				
		def FList = new FulfillmentList(year: 2012, day: 12, month: 1, quantity: 5).save()
		
			
		bookRequest.addToFulfillmentLists(FList);
		
		BookRequest foundRequest = BookRequest.get(bookRequest.id);
		
		assertEquals(foundRequest.fulfillmentLists.size(), 1);
		
		
	}
	
}
